//
//  FWParse.m
//  OCPropertyExport
//
//  Created by 曾少伟 on 2019/12/15.
//  Copyright © 2019 zsw. All rights reserved.
//

#import "FWParse.h"


@implementation FWParse
+ (NSMutableArray <SWPropertyModel *> *)parseWithString:(NSString *)string {
    NSArray *arr = [string componentsSeparatedByString:@"\n"];
    NSMutableArray *marr = [NSMutableArray array];
    for (NSString *content in arr) {
        if (content.length == 0) continue;
        if ([content containsString:@"string"] || [content containsString:@"integer"] || [content containsString:@"bool"] || [content containsString:@"number"]) {
            SWPropertyModel *model = [SWPropertyModel new];
            [marr addObject:model];
            NSArray *nameAndTypeArr = [content componentsSeparatedByString:@"\t"];
            model.name = nameAndTypeArr.firstObject;
            model.type = nameAndTypeArr.lastObject;
        } else {
            SWPropertyModel *model = marr.lastObject;
            model.markdown = content;
        }
    }
    return marr;
}
@end
